Micron Document
🎖️GitЯра🎖️

Node / meshtastic / Meshtastic-Android / files / core / ui / src / commonMain / kotlin / org / meshtastic / core / ui / util / LocalEventBranding.kt

Displaying Raw • Download

core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/util/LocalEventBranding.kt bf929c20f274232e0eb8ddc19b2dc82403e99e5b (bf929c20) Text, 2.55 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.ui.util

Tff7b72import T7ee787androidx.compose.runtime.compositionLocalOf
Tff7b72import T7ee787androidx.compose.ui.graphics.Color
Tff7b72import T7ee787org.jetbrains.compose.resources.DrawableResource
Tff7b72import T7ee787org.meshtastic.core.model.EventFirmwareEdition
Tff7b72import T7ee787org.meshtastic.core.resources.Res
Tff7b72import T7ee787org.meshtastic.core.resources.img_event_hamvention

T8b949e/**
* Provides the active [EventFirmwareEdition] (if any) to the composition tree. When a connected device reports an event
* firmware edition, this local is populated at the app root so that
* [MainAppBar][org.meshtastic.core.ui.component.MainAppBar] can display event branding automatically — no per-screen
* wiring needed.
*/
Tf0883e@SuppressTb4b4b4(Ta5d6ff"Ta5d6ffCompositionLocalAllowlistTa5d6ff"Tb4b4b4)
Tff7b72val Te6edf3LocalEventBranding Tff7b72= Te6edf3compositionLocalOfTff7b72<Te6edf3EventFirmwareEdition?Tff7b72> Tb4b4b4{ Tff7b72null Tb4b4b4}

T8b949e/**
* Bundled branding drawable for an edition, or `null`. The metadata's `iconUrl` is null until icons are hosted, so the
* one drawable we ship stays code-mapped here; remove this once icons are loaded from [EventFirmwareEdition.iconUrl].
*/
Tff7b72fun Td2a8ffeventIconForTb4b4b4(Te6edf3editionNameTb4b4b4: Tffa657StringTb4b4b4)Tb4b4b4: Te6edf3DrawableResource? Tff7b72= Tff7b72when Tb4b4b4(Te6edf3editionNameTb4b4b4) Tb4b4b4{
Ta5d6ff"Ta5d6ffHAMVENTIONTa5d6ff" Tff7b72-Tff7b72> Te6edf3ResTb4b4b4.Te6edf3drawableTb4b4b4.Te6edf3img_event_hamvention
Tff7b72else Tff7b72-Tff7b72> Tff7b72null
Tb4b4b4}

T8b949e/** Parses the edition's `#RRGGBB` [EventFirmwareEdition.accentColor] into a [Color], or `null` if absent/malformed. */
Tff7b72fun Te6edf3EventFirmwareEditionTb4b4b4.Td2a8ffaccentColorOrNullTb4b4b4(Tb4b4b4)Tb4b4b4: Te6edf3Color? Tb4b4b4{
Tff7b72val Te6edf3rgb Tff7b72=
Te6edf3accentColorTff7b72?.Te6edf3trimTb4b4b4(Tb4b4b4)Tff7b72?.Te6edf3removePrefixTb4b4b4(Ta5d6ff"Ta5d6ff#Ta5d6ff"Tb4b4b4)Tff7b72?.Te6edf3takeIf Tb4b4b4{ Tffa657itTb4b4b4.Te6edf3length Tff7b72=Tff7b72= Te6edf3RGB_HEX_LENGTH Tb4b4b4}Tff7b72?.Te6edf3toIntOrNullTb4b4b4(Te6edf3HEX_RADIXTb4b4b4)
Tff7b72?: Tff7b72return Tff7b72null
Tff7b72return Te6edf3ColorTb4b4b4(
Te6edf3red Tff7b72= Tb4b4b4(Te6edf3rgb Te6edf3shr Te6edf3RED_SHIFTTb4b4b4) Te6edf3and Te6edf3BYTE_MASKTb4b4b4,
Te6edf3green Tff7b72= Tb4b4b4(Te6edf3rgb Te6edf3shr Te6edf3GREEN_SHIFTTb4b4b4) Te6edf3and Te6edf3BYTE_MASKTb4b4b4,
Te6edf3blue Tff7b72= Te6edf3rgb Te6edf3and Te6edf3BYTE_MASKTb4b4b4,
Tb4b4b4)
Tb4b4b4}

Tff7b72private Tff7b72const Tff7b72val Te6edf3RGB_HEX_LENGTH Tff7b72= T79c0ff6
Tff7b72private Tff7b72const Tff7b72val Te6edf3HEX_RADIX Tff7b72= T79c0ff1T79c0ff6
Tff7b72private Tff7b72const Tff7b72val Te6edf3RED_SHIFT Tff7b72= T79c0ff1T79c0ff6
Tff7b72private Tff7b72const Tff7b72val Te6edf3GREEN_SHIFT Tff7b72= T79c0ff8
Tff7b72private Tff7b72const Tff7b72val Te6edf3BYTE_MASK Tff7b72= T79c0ff0Te6edf3xFF

Served by rngit 1.5.0 - Generated in 0.04s